<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<!-- 7. 一个密码输入框，带有一个按钮用于切换显示或隐藏密码文本。 -->

<body>
  <div id="app">
    <input type="password" v-model="password" v-if="!show">
    <input type="pass" v-model="password" v-if="show">
    <button @click="add">{{ show? '隐藏密码' : '显示密码' }}</button>

  </div>
</body>
<script src="./vue.js"></script>
<script>
  const { createApp, ref } = Vue;
  createApp({
    setup() {

      const password = ref('');
      const show = ref(false);

      function add() {
        show.value = !show.value;
      }

      return {
        password,
        show,
        add
      }
    }
  }).mount('#app')
</script>

</html>